package com.yunyao.common.constant.enums;

import lombok.Getter;

/**
 * 供货状态
 * @author chenyejian
 * @date 2024-07-21
 */
@Getter
public enum SupplyStatus {
//    WAIT_SUBMIT("auditStatus=0", "待提交"),
//    APPROVAL_IN_PROGRESS("auditStatus=1", "审批中"),
//    APPROVAL_REJECTED("auditStatus=3", "审批驳回"),
//    APPROVAL_REVOKE("auditStatus=4", "撤回"),
//    PROJECT_ACCEPTANCE_APPROVAL_REVOKE("auditStatus=4&supplyStatus=8", "项目验收审批撤回"),
//    PROJECT_ACCEPTANCE_APPROVAL_REJECTED("auditStatus=3&supplyStatus=8", "项目验收审批驳回"),
//    SUPPLIER_AWAITING_CONFIRMATION("supplyStatus=1", "待供应商确认"),
//    SUPPLIER_CONFIRMATION_REJECTED("supplyStatus=2", "待供应商确认驳回"),
//    SUPPLY_ING("supplyStatus=3", "待供货"),
//    SUPPLY_IN_PROGRESS("supplyStatus=4", "供货中"),
//    SUPPLY_COMPLETED("supplyStatus=5", "供货完成"),
//    SUPPLY_DELAYED("supplyStatus=6", "供货延迟");

    SUPPLIER_AWAITING_CONFIRMATION(1, "待供应商确认"),
    SUPPLIER_CONFIRMATION_REJECTED(2, "待供应商确认驳回"),
    SUPPLY_ING(3, "待供货"),
    SUPPLY_IN_PROGRESS(4, "供货中"),
    SUPPLY_COMPLETED(5, "供货完成"),
    SUPPLY_DELAYED(6, "供货延迟"),
    SUPPLY_COMPLETION_ACCEPTANCE(8, "项目验收");

    private final Integer type;
    private final String description;

    SupplyStatus(int type, String description) {
        this.type = type;
        this.description = description;
    }

    /**
     * 可以根据 type 获取枚举实例
     */
    public static String getDescriptionByType(Integer type) {
        for (SupplyStatus status : SupplyStatus.values()) {
            if (type == (status.getType())) {
                return status.getDescription();
            }
        }
        return null;
    }

    /**
     * 可以根据 description 获取枚举实例
     */
    public static Integer getTypeByDesc(String description) {
        for (SupplyStatus status : SupplyStatus.values()) {
            if (description.equalsIgnoreCase(status.getDescription())) {
                return status.getType();
            }
        }
        return null;
    }
}
